##### My (demuredemeanor) bashrc sub source machine settings script
# Uses tabstop=4; shiftwidth=4 tabs; foldmarker={{{,}}};
# https://notabug.org/demure/dotfiles/
# legacy repo http://github.com/demure/dotfiles
# vim:set syntax=sh:

### Settings ### {{{
	### Mac Settings ### {{{
	if [ $OSTYPE == 'darwin13' ]; then
		### Mac Sourcing ### {{{
		__ssh_agent

		## Add git completion
		if [ -f `brew --prefix`/etc/bash_completion ]; then
			source `brew --prefix`/etc/bash_completion
		fi

		## Brew completion
		if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then
			source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
		fi

			### stderred ### {{{
			#if [ -f /Projects/git/stderred/build/libstderred.dylib${DYLD_INSERT_LIBRARIES:+:$DYLD_INSERT_LIBRARIES} ]; then

				#export DYLD_INSERT_LIBRARIES="/Projects/git/stderred/build/libstderred.dylib${DYLD_INSERT_LIBRARIES:+:$DYLD_INSERT_LIBRARIES}"
				##export STDERRED_ESC_CODE=$(printf "\e[1;31m")
			#fi
			### End stderred ### }}}
		### End Mac Sourcing ### }}}

		### Mac Aliases ### {{{
		if [[ $- == *i* ]]; then
			alias google='ping -c 1 www.google.com && growlnotify -m "google pinged"'
			alias ardrestart='sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent -menu'
			alias vi='vim'
			alias fvreboot='sudo fdesetup authrestart'
			alias rebuild_open_with='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"'

			## Aliases for nicing
			alias fast='sudo nice -n -10'
			alias slow='nice -n 20'
			### End Mac Aliases ### }}}
		fi
	fi
	### End Mac Settings ### }}}

	### MA Settings ### {{{
	if [ $HOSTNAME == 'ma.sdf.org' ]; then
		export PATH=/usr/pkg/bin:/usr/local/bin:/usr/bin:/bin
		export TZ=EST5EDT
		source /etc/bash_completion.d/git		## Add git completion

		if [[ $- == *i* ]]; then
			alias bb='bboard'
			alias mutt='~/bin/mutt'
			unalias svi
		fi

		#__ssh_agent							## No longer main server
	fi
	### End MA Settings ### }}}

	### For pi ### {{{
	if [ $HOSTTYPE == 'arm' ]; then
		source /etc/bash_completion.d/git		## Add git completion

		if [[ $- == *i* ]]; then
			alias ls='ls --color=auto'
			alias vi='vim'
			alias vnc='vncserver :1 -geometry 1024x700 -depth 24'
			alias cdtrans='cd /var/lib/transmission-daemon/downloads'
		fi
		__ssh_agent
	fi
	### End For pi ### }}}

	### For iOS ### {{{
	if [ $OSTYPE == 'darwin9' ]; then
		if [[ $- == *i* ]]; then
			alias svi='sudo -E vi'
		fi
	fi
	### End For iOS ### }}}

	### For #!, and debian Including Laptop and Netbook ### {{{
	if [[ $MACHTYPE == 'x86_64-pc-linux-gnu' || $MACHTYPE == 'i486-pc-linux-gnu' ]]; then
		if [[ $- == *i* ]]; then
			alias ls='ls --color=auto'
			alias vi='vim'
			alias mp='mpv'
			alias ssht='sshuttle --dns -vr ma 0/0'
			alias hdmi-mirror='xrandr --output HDMI1 --mode 1360x768'
			alias hdmi-second='xrandr --output HDMI1 --mode 1360x768 --right-of LVDS1'
			alias hdmi-off='xrandr --output HDMI1 --off'
			alias sd-card='sudo setpci -s 00:1c.2 0x50.B=0x41'
			alias xc="xclip -selection c"
			alias www-logs='sudo lnav /var/log/nginx/access.log /var/log/nginx/error.log /var/log/fail2ban.log'

			export NVIM_HOME="$HOME/Dropbox/Notational Data"
		fi

		#if [[ $HOSTNAME != "vps-of-doom" ]]; then
		#__gpg_agent
		#fi

		__ssh_agent
	fi
	### End For #! ### }}}

	### For SDF Main Cluster ### {{{
	if [[ "$MACHTYPE" == "x86_64--netbsd" && "$OSTYPE" == "netbsd" ]]; then
		#LSCOLORS='exfxcxdxbxegedabagacad'
		export TZ=EST5EDT

		if [[ $- == *i* ]]; then
			alias help='/usr/local/bin/help'
			alias bb='bboard'
			alias cdircd='cd /sys/pkg/etc/unrealircd/'
			unalias svi
			#alias ls='colorls -G'
		fi
	fi
	### End For SDF Main Cluster ### }}}

	### For OpenWrt ### {{{
		if [ "$MACHTYPE" == "mips-openwrt-linux-gnu" ]; then
			alias opkgup="eval \$(opkg list_installed | sed 's/ - .*//' | sed 's/^/opkg upgrade /')"
			unalias vi
			unalias grep
		fi
	### End For OpenWrt ### }}}

	### Testing ### {{{
	## Fix tmux DISPLAY
	# "Yubinkim.com totally wrote this one herself"
	# "Run this script outside of tmux!"
#	for name in `tmux ls -F '#{session_name}'`; do
#		tmux setenv -g -t $name DISPLAY $DISPLAY #set display for all sessions
#	done
	### End Testing ### }}}
### End Settings ### }}}
